<template>
  <div>
    <h1>整合ECharts</h1>
    <div id="main" style="width: 1200px; height: 800px"></div>
  </div>
</template>

<script>
export default {
  name: "c1",
  data() {
    return {
      echartsList:[]
    }
  },
  mounted() {
    this.groupByDid();    
  },
  methods: {
    groupByDid(){
       this.$axios
        .get("http://localhost:9000/userEmp/selNum")
        .then((res) => {
          if (res.data.code == 200) {
            this.echartsList = res.data.data.echartsList;
            this.getChar();
          }
        });

    },
    getChar() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = this.$echarts.init(document.getElementById("main"));
      var option = {
        title: {
          text: "Referer of a Website",
          subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data:this.echartsList,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
};
</script>